<template>
	<view class="">
		<view class="head_main" style="background-image:linear-gradient(to right,#00828A, #4CA7AD);">
			<view style="padding-top:95rpx;padding-left:20rpx;padding-bottom:35rpx;z-index: 999;">
				<u-icon name="https://resourse.cnlhjt.com/upload/20220825/3b2ac9bb4fed1fd4d677edecafcbf66c.png" label="邻里共享" labelColor="#fff" space="6">
				</u-icon>
			</view>
		</view>
		<view style="height:155rpx;"></view>
		<view class="wrap" style="background-color:#f8f8f8;">
			<view style="height: 30rpx;"></view>
			<u-swiper :list="bannerList" @click="intoBanner" keyName="image" radius="8" :indicator="true"
				style="margin-top: 20rpx;">
			</u-swiper>

			<view style="margin-top:30rpx;">
				<u-grid :border="false" col="2">
					<u-grid-item v-for="(item,index) in nav" :key="index">
						<view v-if="index <= 3">
							<image @click="navInto(item.id,item.image)" :src="item.icon"
								style="width:330rpx;height:165rpx;border-radius: 20rpx;">
							</image>
						</view>
					</u-grid-item>
				</u-grid>

				<u-toast ref="uToast" />
			</view>
			<!-- 热门推荐 -->
			<view class="uni-flex-center" style="margin-top: 15rpx;" v-if="hotTopic==true">
				<view class="main-service uni-cell-90">
					<view class="title">
						<view style="display: flex; ">
							<u-image :src="appTitle.rmtj" width="80" height="30" mode="aspectFit"></u-image>
							<text
								style="color: #999999; font-weight: 400;font-size: 28rpx; line-height: 56rpx;text-align: right; width:100%;"
								@click="tomoreshare">更多
								<!-- <u-icon style="display: inline-block !important;" name="arrow-right" color="#999999" size="14"></u-icon> -->
							</text>
						</view>
					</view>
				</view>

			</view>
			<view class="u-demo-block__content" style="margin-top:20rpx;" v-if="hotTopic==true">

				<view style="clear: both;"></view>
				<u-row customStyle="margin-bottom: 10px">
					<u-col span="12">
						<view class="demo-layout">
							<u-image :src="hotService[2].image" width="100%" height="210rpx" mode="widthFill"
								@click="lattice">
							</u-image>
						</view>
					</u-col>
				</u-row>
				<u-row justify="space-between" customStyle="background-color:#f5f1e3;border-radius: 20rpx;">
					<u-col span="2">
						<view class="demo-layout"
							style="height: 195rpx; background-color: #0B868E;text-align: right; border-top-left-radius: 20rpx; border-bottom-left-radius: 20rpx; padding-top: 10rpx;">
							<text class="hot_title">热</text>
							<text class="hot_title">门</text>
							<text class="hot_title">共</text>
							<text class="hot_title">享</text>
						</view>
					</u-col>
					<u-col span="10">
						<view class="demo-layout" style="height:100%;">
							<text v-for="(item, index) in hotShare" :key="index" @click="latticeNav(item)"
								style="word-wrap: break-word;
				word-break: normal; font-size: 30rpx;  color: #b7a771; line-height: 80rpx; margin-left: 4%; padding: 10rpx 3%; border: 1rpx solid #b7a771; border-radius: 50rpx;">
								<text>{{item.name}}</text>
							</text>
						</view>
					</u-col>
				</u-row>
			</view>
			<!-- 共享厨房 -->
			<view class="uni-flex-center" style="margin-top: 15rpx;">
				<view class="main-service uni-cell-90" v-for="(item, index) in nav" :key="index" v-if="index > 3">
					<view class="title title1">{{item.name}}</view>
					<view style="width: 100%; height: 265rpx;margin-top:10rpx;border-radius: 20rpx;overflow: hidden;"
						@click="navInto(item.id,item.image)">
						<u-image :src="item.image" mode="widthFix" width="100%" height="265rpx"></u-image>
					</view>
				</view>
			</view>

		<u-toast ref="uToast"></u-toast>
		</view>
	</view>
</template>

<script>
	import {
		getAdjacentNav,
		getBanner
	} from "@/service/configService.js";
	import {
		getTopic,
		getServiceItems
	} from "@/service/shareService.js";
	export default {
		data() {
			return {
				appTitle: this.$store.state.appTitle,
				bannerList: [],
				nav: [],
				hotService: [{
						name: '免费看护',
						image: 'https://s4.ax1x.com/2022/02/17/H519Zn.png'
					},
					{
						name: '作业辅导',
						image: 'https://s4.ax1x.com/2022/02/17/H51Sqs.png'
					},
					{
						name: '共享格子铺',
						image: 'https://resourse.cnlhjt.com/upload/20220825/f9dae799cff8f15940b04e7a34c51f06.png'
						// image: 'https://s4.ax1x.com/2022/02/17/H53wnJ.png'
					}
				],

				near: [],
				hotShare: [],
				hotTopic: false
			}
		},
		mounted() {
			getBanner({
				type: 1
			}).then(this.getBanner);
			getAdjacentNav().then(this.getAdjacentNav);
			getTopic({
				page: 1,
				limit: 6
			}).then(this.getTopic);
			getServiceItems().then(this.getServiceItems);
		},
		methods: {
			getServiceItems(e) {
				if (e.code == 200) {
					this.near = e.result;
				}
			},
			getBanner(e) {
				if (e.code == 200) {
					this.bannerList = e.result;
				}
			},
			getAdjacentNav(e) {
				if (e.code == 200) {
					this.nav = e.result;
				}
			},
			getTopic(e) {
				if (e.code == 200) {
					this.hotTopic = true;
					this.hotShare = e.result;
				}
			},
			navInto(index,image) {
				switch (index) {
					case 1:
						this.$u.route({
							url: '/pagesShare/schoole/index',
							params: {
								nid: index,
								image:image
							}
						});
						break;
					case 2:
						this.$u.route({
							url: '/pagesShare/lattice/index',
							params: {
								nid: index,
								image:image
							}
						});
						break;
					case 3:
						this.$u.route({
							url: '/pagesShare/tool/index',
							params: {
								nid: index,
								image:image
							}
						});
						break;
					case 4:
						this.$u.route({
							url: '/pagesShare/yanglao/index',
							params: {
								nid: index,
								image:image
							}
						});
						break;
					case 5:
						// this.$u.route({
						// 	url: '/pagesShare/kitchen/index',
						// 	params: {
						// 		nid: index,
						// 		image:image
						// 	}
						// });
						this.$refs.uToast.show({
							type: 'error',
							title: '失败',
							icon:false,
							message: '智慧生活，敬请期待',
							complete() {
								
							}
						})
						break;
					default:
						this.$refs.uToast.show({
							type: 'error',
							title: '失败',
							icon:false,
							message: '智慧生活，敬请期待',
							complete() {
								
							}
						})
				}
			},
			tomoreshare() {
				this.$u.route({
					url: '/pagesShare/index/topicmore',
					params: {

					}
				});
			},
			freeCare() {
				this.$u.route({
					url: '/pagesShare/schoole/join',
					params: {
						nid: 1
					}
				});
			},
			workHelp() {
				this.$u.route({
					url: '/pagesShare/schoole/join',
					params: {
						nid: 2
					}
				});
			},
			lattice() {
				let lattice = false;
				this.nav.forEach((item, index) => {
					if (item.id == 2) {
						lattice = true;
					}
				});
				if (lattice == false) {
					return;
				}
				this.$u.route({
					url: '/pagesShare/lattice/index',
					params: {

					}
				});
			},
			latticeNav(item) {
				let lattice = false;
				this.nav.forEach((item, index) => {
					if (item.id == 2) {
						lattice = true;
					}
				});
				if (lattice == false) {
					this.$refs.uToast.show({
						type: 'error',
						title: '失败',
						icon:false,
						message: "智慧生活，敬请期待",
					})
					return;
					
				}
				this.$u.route({
					url: '/pagesShare/lattice/nav-index',
					params: {
						item: JSON.stringify(item)
					}
				})
			},
			intoBanner(index) {
				let id = this.bannerList[index].id;
				this.$u.route({
					url: '/pagesHome/index/article',
					params: {
						id: id
					}
				})
			},
			shareItem(item) {
				if (item.nid == 1) {
					this.$u.route({
						url: '/pagesShare/schoole/join',
						params: {
							nid: item.id,
							memo: item.memo
						}
					})
				} else if (item.nid == 4) {
					this.$u.route({
						url: '/pagesShare/yanglao/join',
						params: {
							nid: item.id,
							memo: item.memo
						}
					})
				} else {
					this.$refs.uToast.show({
						type: 'error',
						title: '失败',
						icon:false,
						message: "智慧生活，敬请期待",
					})
				}

			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f8f8f8;
	}
	.head_main{
		position: fixed;
		top:0;
		left:0;
		width:100%;
		z-index:999;
	}
	.main-service {
		background-color: transparent;
		box-shadow: none;
	}

	.main-service .title1{
		padding-left:0;
		background-position: 0% 90%;
		background-image: url('https://resourse.cnlhjt.com/upload/20220825/53079139ae5b67d1270fc35fefba8d1e.png');
		background-size: 70px;
		background-repeat: no-repeat;
	}

	.wrap {
		width: 94%;
		padding-left: 3%;
		padding-right: 3%;
		padding-bottom: 20rpx;
	}

	.hot_title {
		font-size: 30rpx;
		color: #FFFFFF;
		margin-left: 35rpx;
		padding-right: 40rpx;
	}

	.scroll-list {
		margin-left: 20rpx;
		@include flex(column);

		&__goods-item {
			margin-right: 20rpx;

			&__image {
				width: 86px;
				height: 65px;
				border-radius: 4px;
			}

			&__text {
				color: #126970;
				text-align: center;
				font-size: 12px;
				margin-top: 5px;
			}
		}

		&__show-more {
			background-color: #fff0f0;
			border-radius: 3px;
			padding: 3px 6px;
			@include flex(column);
			align-items: center;

			&__text {
				font-size: 12px;
				width: 12px;
				color: #f56c6c;
				line-height: 16px;
			}
		}
	}

	.iconType {
		display: flex;
		background-color: #FFFFFF;
		justify-content: space-between;
	}

	.icon {
		height: auto;
	}

	.item {
		width: 100%;
		text-align: center;
		color: #13227a;
		font-size: 28rpx;
		justify-content: space-between;
	}
</style>
